package com.szxy.plugin;

import com.deepoove.poi.data.RowRenderData;
import com.deepoove.poi.policy.DynamicTableRenderPolicy;
import com.deepoove.poi.policy.MiniTableRenderPolicy;
import org.apache.poi.xwpf.usermodel.XWPFTable;

import java.util.List;

/**
 * @Author: zwz
 * @Date:2020/7/28 14:47
 * @Description:com.szxy.plugin
 * @Version:1.0
 **/
public class OneCommonTablePolicy extends DynamicTableRenderPolicy {

    /**
     * 跳过的行数
     */
    public static final int SKIP_ROWS = 1;

    @Override
    public void render(XWPFTable table, Object data) {
        // 数据校验
        if(null == data)  return;

        List<RowRenderData> dataList = (List<RowRenderData>) data;

        if (null != dataList) {
            for (int i = 0; i < dataList.size(); i++) {
                MiniTableRenderPolicy.renderRow(table, i+ SKIP_ROWS, dataList.get(i));
            }
        }
    }
}

